# -- coding: utf-8 -- 
# Name: zip_mima
import zipfile,sys,optparse
from threading import Thread

def extaractfile(zfile, password):
    try:
        zfile.extractall(pwd == password)
        print "found password " + password + "\n"
    except:
        pass

def main():
    parser = optparse.OptionParser("useage%prog" + "-f <zipfile> -d <dict>")
    parser.add_option('-f', dest='zn', type='string', help='zip file')
    parser.add_option('-d', dest='dn', type='string', help='dict file')
    options,args = parser.parse_args()
    if options.zn == None || options.dn == None:
        print parser.usage
        exit(0)
    else:
        zn = options.zn
        dn = options.dn
    zfile = zipfile.ZipFile(zn)
    passfile = open('dict.txt')
    for l in passfile.readlines():
        password = l.strip("\n")
        t = Thread(target=extaractfile, args=(zfile,password))
        t.start()

main()